/**
 * Created by yjj on 2017/5/3.
 */
import axios from 'axios';
import {API_NEW_VERSION} from '../api';

const ORGANIZATION_RADIATE_SCOPES = API_NEW_VERSION + 'organizations/radiate_scope';
export const getOrganizationById = id => {
  return axios.get(API_NEW_VERSION + '/organizations/' + id);
};

export const organizationTree = () => {
  return axios.get(API_NEW_VERSION + 'organizations/tree');
};

export const deleteOrganization = (ids) => {
  return axios.delete(API_NEW_VERSION + 'organizations/' + ids);
};

export const saveOrganization = (param) => {
  return axios.post(API_NEW_VERSION + 'organizations', param);
};

export const addResource = (id, param) => {
  return axios.post(API_NEW_VERSION + 'organizations/' + id + '/resources', param);
};

export const getResource = (id) => {
  return axios.get(API_NEW_VERSION + 'organizations/' + id + '/resources');
};

export const removeUsers = (id, userIds) => {
  return axios.delete(API_NEW_VERSION + 'organizations/' + id + '/users/' + userIds);
};

export const addUsers = (id, userIds) => {
  return axios.post(API_NEW_VERSION + 'organizations/' + id + '/users/' + userIds);
};

/**
 * 保存机构的辐射管理城市
 * @param param
 * @returns {AxiosPromise}
 */
export const addOrganizationRadiateScopes = (param) => {
  return axios.post(ORGANIZATION_RADIATE_SCOPES, param);
};

/**
 * 根据机构id，获取当前机构的辐射城市
 * @param organizationId
 * @returns {AxiosPromise}
 */
export const getOrganizationRadiateScopes = (params) => {
  return axios.get(ORGANIZATION_RADIATE_SCOPES, {params: params});
};
/**
 * 删除机构辐射城市
 * @param params
 * @returns {AxiosPromise}
 */
export const deleteOrganizationRadiateScopes = (id) => {
  return axios.delete(ORGANIZATION_RADIATE_SCOPES + '/' + id);
};
